package com.itheima.reggie.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.reggie.pojo.DishFlavor;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DishFlavorDao extends BaseMapper<DishFlavorDao> {
    @Insert("insert into dish_flavor values (NULL,#{dishId},#{name},#{value},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    void save(DishFlavor dishFlavor);

    @Select("select * from dish_flavor where dish_id=#{dishId}")
    List<DishFlavor> findByDishId(Long dishId);

    /**
     * 通过dishId删除相应的口味
     */
    @Delete("delete from dish_flavor where dish_id=#{dishId}")
    int deleteByDishId(Long dishId);
}
